﻿<demo:ViewBase
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:demo="http://schemas.ultimatedemo.com/2012/xaml/presentation"
    xmlns:ultimate="http://schemas.ultimatenavigationframework.com/2011/xaml/presentation"               
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" 
    xmlns:prism="http://www.codeplex.com/prism"
    x:Class="Ultimate.Shell.Views.ShellView"               
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <HyperlinkButton Content="Home" NavigateUri="/Home" FontSize="28" Margin="8"/>
            <HyperlinkButton Content="About" NavigateUri="/About" FontSize="28" Margin="8"/>   
            <Button Name="GoBackButton"                    
                    Margin="2"
                    IsEnabled="{Binding CanGoBack, ElementName=MainFrame}"
                    Content="Go Back"
                    Click="GoBackButton_Click"/>
            <Button Name="GoForwardButton"
                    Margin="2"
                    IsEnabled="{Binding CanGoForward, ElementName=MainFrame}"
                    Content="Go Forward"
                    Click="GoForwardButton_Click"/>
        </StackPanel>
        <!--Note: RegionName must be unique across application-->
        <toolkit:BusyIndicator Grid.Row="1"         
                               BusyContent="{Binding ProgressValue, ElementName=MainFrame}"
                               IsBusy="{Binding IsBusy, ElementName=MainFrame}">
            <ultimate:UltimateNavigationFrame x:Name="MainFrame"
                                                  Source="/Home"                                                  
                                                  IsRoot="True"
                                                  NavigationFailed="MainFrame_NavigationFailed"
                                                  prism:RegionManager.RegionName="ShellRegion">
                <ultimate:UltimateNavigationFrame.UriMapper>
                    <ultimate:UltimateNavigationUriMapper>
                        
                        <ultimate:UltimateNavigationUriMapping Uri="/Home"
                                                               MappedUri="/HomeMainView"
                                                               IsChildFrame="True" />
                        <ultimate:UltimateNavigationUriMapping Uri="/Home/Sub/{id}/Inner/{innerId}"
                                                               MappedUri="/HomeMainView"
                                                               IsChildFrame="True" />
                        <ultimate:UltimateNavigationUriMapping Uri="/Home/Sub/{id}"
                                                               MappedUri="/HomeMainView"
                                                               IsChildFrame="True" />

                        <ultimate:UltimateNavigationUriMapping Uri="/About"
                                                               MappedUri="/AboutMainView" />
                    </ultimate:UltimateNavigationUriMapper>
                </ultimate:UltimateNavigationFrame.UriMapper>
                <ultimate:UltimateNavigationFrame.Authoriser>
                    <ultimate:NavigationAuthoriser ErrorUri="/UnauthorisedView"
                                                     Principal="{Binding Current.User, Source={StaticResource WebContext}}">
                        <ultimate:AuthorisationRule UriPattern="^/About/Sub?">
                            <!--This is the role string, currently will never match so will always show the Unauthorised view-->
                            <ultimate:Allow Roles="Admin" />
                        </ultimate:AuthorisationRule>
                    </ultimate:NavigationAuthoriser>
                </ultimate:UltimateNavigationFrame.Authoriser>
                <!--Handles all exception to ErrorView-->
                <ultimate:ErrorPage ErrorPageUri="/ErrorView"
                                      ExceptionType="Exception" />
            </ultimate:UltimateNavigationFrame>
        </toolkit:BusyIndicator>
    </Grid>
</demo:ViewBase>